package com.aya.activity.platform.newuser;

import com.aya.activity.core.UserActivity;

import java.math.BigDecimal;

/**
 * 手机专享价
 */
public class NewUser implements UserActivity {

    NewUserService phoneService;

    public void setPhoneService(NewUserService phoneService) {
        this.phoneService = phoneService;
    }


    @Override
    public <U> BigDecimal activity(U userId, BigDecimal price) {
        Boolean isPhone = phoneService.selectNewUser(userId);
        if(!isPhone){
            return price;
        }
        BigDecimal newUserMoney = phoneService.selectNewUserMoney();
        return  price.subtract(newUserMoney);
    }
}
